package game.common
{
	import com.greensock.loading.SWFLoader;
	import com.greensock.loading.XMLLoader;
	
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.system.ApplicationDomain;
	
	import game.utils.MassLoader;


	/**
	 * 加载反射类
	 * @author xiezhicheng
	 */
	public class Reflection
	{
		private static var loader:MassLoader = MassLoader.getInstance();
		public static var _swfloader:SWFLoader = loader.loader.getLoader("ui");
		public static var xmlLoader:XMLLoader=loader.loader.getLoader("mapxml");
		public static var dataLoader:XMLLoader=loader.loader.getLoader("dataxml");
		
		public function Reflection()
		{
		}
		
		/**
		 * 获取指定loader的class
		 * @param fullClassName 名称
		 * @param loader LoaderMax
		 * @return 
		 */
		public static function getClass(fullClassName:String):Class
		{
			var ref:Class = _swfloader.getClass(fullClassName);
			return ref;
		}
		
		
		/**
		 * 获取指定loader的bitmapdata
		 * @param fullClassName
		 * @param loader
		 * @return 
		 */
		public static function createBitmapDataInstance(fullClassName:String):BitmapData
		{
			var ref:Class = getClass(fullClassName);
			var mc:MovieClip = new ref() as MovieClip;
			var bmd:BitmapData = new BitmapData(mc.width,mc.height,true,0x000000);
			bmd.draw(mc);
			if (bmd != null)
			{
				return bmd;
			}
			return null;
		}
		
		
		public static function createMovieClip(fullClassName:String):MovieClip
		{
			var ref:Class = getClass(fullClassName);
			var mc:MovieClip = new ref() as MovieClip;
			if (mc) 
			{
				return mc;	
			}
			return null;
		}

	}
}